<template>
  <div>
    <div style="overflow:hidden"
      class="swiper-container2"
      ref="swiper-container2"
     
    >
      <div class="swiper-wrapper" @click="Tologin"  v-for="(item, key) in array"
      :key="'info_'+key">
        <!-- <template v-for="(item,key) in array"> -->
        <div class="swiper-slide" style="height: 350px">
          <img class="data1" :src="item.coverImage" />
          <p class="data2">{{ item.coverTitle }}</p>
        </div>
        <!-- </template> -->
      </div>
    </div>
  </div>
</template>

<script>
import "../../src/assets/css/swiper-bundle.css";
import Swiper from "swiper";
import axios from "axios";

export default {
  data() {
    return {
      mySwiper: null,
      array: [],
    };
  },
  async created() {
    // 发起网络请求
    const url =
      "https://api.hongbeibang.com/recommend/getRandContent?_t=1607308941754&type=3&pageSize=10&timestamp=1607308941731";
    let ret = await axios.get(url);
    this.array = ret.data.data.data;
    console.log(ret.data.data.data);
    //       this.Footerone= ret.data.data.Footerone
    //       console.log(this.Footerone)
  },
  methods:{
    Tologin(){
      this.$router.push("/Login")
    }
  },
  updated() {
    this.$nextTick(() => {
      this.mySwiper = new Swiper(this.$refs["swiper-container2"], {
        // direction: "vertical", // 垂直切换选项
        loop: false, // 循环模式选项
        slidesPerView: 2,

        // 如果需要分页器
        pagination: {
          el: ".swiper-pagination",
        },

        // 如果需要前进后退按钮
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },

        // 如果需要滚动条
        scrollbar: {
          el: ".swiper-scrollbar",
        },
      });
    });
    // props:{
    //   props:Object
    // }
  },
};
</script>

<style lang="scss" scoped>
html,
body {
  position: relative;
  height: 100%;
}

body {
  background: #eee;
  font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #000;
  margin: 0;
  padding: 0;
}

.swiper-container2 {
  box-sizing: border-box;
  width: 100%;
  // float: left;
  display: flex;
  //   height: 100%;
}

.swiper-slide {
  float: left;
  // text-align: center;
  font-size: 18px;
  background: #fff;
  // height: 350px;
  // width: 310px;
  /* Center slide text vertically */
  // display: -webkit-box;
  // display: -ms-flexbox;
  //   display: -webkit-flex;
  // display: flex;
  // -webkit-box-pack: center;
  // -ms-flex-pack: center;
  // -webkit-justify-content: center;
  // justify-content: center;
  // -webkit-box-align: center;
  // -ms-flex-align: center;
  // -webkit-align-items: center;
  // align-items: center;
  width: 210px;
  height: 287px;
}
.data1 {
  width: 176.64px;
  height: 284.4px;
}
.data2 {
  font-size: 15px;
  color: #4a4945;
  font-weight: bold;
}
</style>
